<?php
/**
 *	@name		V认证
 *	@author		Jeffery
 *	@qq			1017756891
 *	@email		1017756891@qq.com
 *	@website	http://www.iweitao.net
**/
define('IN_AUTHENTICATE',TRUE);

require_once "core.php";

class plugin_authenticate {

	function plugin_authenticate() {
		global $_G;
		if(!$_G['cache']['plugin']['authenticate']['open']) {
			return false;
		}
		$authenticate = checkroot_authenticate();
		$langs = $authenticate['lang']; //获取后台语言包
		$langs = checkload_authenticate($langs);
		$lang = loadlang_authenticate($langs); //加载后台语言包文件
		return $lang;
	}

	function global_usernav_extra1() {
		global $_G;
		if(!$_G['cache']['plugin']['authenticate']['headnotice']) {
			return false;
		}
		$lang = $this->plugin_authenticate();
		if($this->user_info($_G['uid'])) {
			return "<img src='./source/plugin/authenticate/image/certification1.png'>";
		} else {
			return "<b ><a style='color:red;'href='home.php?mod=spacecp&ac=plugin&op=profile&id=authenticate:V'>".$lang[19]."</a></b>";
		}
	}
	
	function user_info($uid) {
		global $_G;
		$fetch = DB::query("SELECT * FROM `".DB::table("weitao_authenticate")."` WHERE `uid` = '$uid' AND `status` = 1");
		if(mysql_fetch_array($fetch)) {
			$fetch = DB::query("SELECT * FROM `".DB::table("weitao_authenticate")."` WHERE `uid` = '$uid'");
			while($query = mysql_fetch_array($fetch)) {
				$array = array(
					'uid' => $query['uid'],
					'username' => $query['username'],
					'name' => $query['name'],
					'phone' => $query['phone'],
					'email' => $query['email'],
					'QQ' => $query['QQ'],
					'idcode' => $query['idcode'],
					'index' => $query['toppath'],
					'bottom' => $query['bottompath'],
					'status' => $query['status'],
				);
			}
			return $array;
		} else {
			return false;
		}
	}
	
	function viewthread_sidetop_output() {
		global $_G,$postlist;
		if(!$_G['cache']['plugin']['authenticate']['treaddetail']) {
			return array();
		}
		foreach($postlist as $pid => $v) {
			if($this->user_info($v['authorid'])) {
				$lang = $this->plugin_authenticate();
				$view_sign[] = "<img style='padding-left:20px;' src='./source/plugin/authenticate/image/certification1.png'><a style='color:red;font-weight:bold;padding-left:5px;'href='home.php?mod=spacecp&ac=plugin&op=profile&id=authenticate:V'>".$lang[35]."</a>";
			} else {
				$lang = $this->plugin_authenticate();
				$view_sign[] =  "<b ><a style='color:red; padding-left:20px;'href='home.php?mod=spacecp&ac=plugin&op=profile&id=authenticate:V'>".$lang[19]."</a></b>";
			}
		}
	//	var_dump($view_sign);
		return $view_sign;
	}
}
class plugin_authenticate_forum extends plugin_authenticate {
	function forumdisplay_author_output() {
		global $_G;
		$threadlist = $_G['forum_threadlist'];
		foreach($threadlist as $k => $v) {
			if($this->user_info($v['authorid'])) {
				$sign[$k] = "<img style='float:right; margin-right:50px;' src='./source/plugin/authenticate/image/certification1.png'>";
			}
		}
		return $sign;
	}
	
	function forumdisplay_kkvip_output(){
		global $_G;
		$usercolor = $_G['cache']['plugin']['authenticate']['usercolor'];
		foreach ($_G['forum_threadlist'] as $key=>$thread){
			if ($this->user_info($thread['authorid'])){
				if (!$thread['highlight']){
					$subject = $_G['forum_threadlist'][$key]['subject'];

					if ($_G['cache']['plugin']['authenticate']['userweight']){
						$subject="<b> $subject </b>";
					}
					$subject="<font color='$usercolor'> $subject </font>";
					$_G['forum_threadlist'][$key]['subject']= $subject;
				}
			}
		}
	}
}
?>